<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button>点我发消息</button>
  <script>
    const ws = new WebSocket('ws://localhost:7000');
    document.querySelector('button').addEventListener('click', () => {
      ws.send(JSON.stringify({ type: 'updateChatHistory' }));
    })


    ws.addEventListener('message', ({ data }) => {
      const result = JSON.parse(data)
      console.log(result)
    })

  </script>
</body>

</html>